#include<bits/stdc++.h>
using namespace std;
int r[100005];
queue<int> q;
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    int n;cin>>n;
    if(n<=30){
        int ans=0,mint=1e5+1;
        for(int i=1;i<=n;i++){
            int x;cin>>x;
            r[x]++;mint=min(mint,x);
        }
        for(int i=1;i<=1e5;i++){
            int sz=q.size();
            int gs=min(sz,r[i]);
            for(int qwer=1;qwer<=gs;qwer++) q.pop(),ans++;
            for(int qwer=1;qwer<=max(0,r[i]-gs);qwer++) q.push(i);
        }
        n-=ans;
        while(!q.empty()){
            if(q.front()!=mint) n--;
            q.pop();
        }
        cout<<n;
    }
    else{
        int gs1=0,gs2=0;
        for(int i=1;i<=n;i++){
            int x;cin>>x;
            if(x==1) gs1++;
            else gs2++;
        }
        cout<<n-min(gs1,gs2);
    }
    return 0;
}
